//南航明珠商城-设置过期商品.js
$(function(){
		   var selectedProductIds = parent.document.getElementById("productIds").value;
		   var productIdArr = selectedProductIds.split(",");
		   var j = 0 ;
		   for(var i=0;i<productIdArr.length;i++){
			 if($("#chk"+productIdArr[i]).length > 0){
				 $("#chk"+productIdArr[i]).attr("checked",true);
				 j++;
			 }
			 if(j == 10){
				 $("#chkAll2").attr("checked",true);
			 }
		   }
	});
	
function check_expire_product(){
	var selectedProductIds = parent.document.getElementById("productIds").value;
	if(selectedProductIds == ""){
		layer.alert("请选择商品！");
		return false;
	}
	layer.confirm("确定要将商品添加到过期列表中?",function(){
		layer.closeAll('dialog');
		var layer_load_window = layer.load(2); 
		 $.ajax({
				url : path + "/product/modify_product_expire",
				cache : false,
				type : 'post',
				dataType : 'text',
				data :{"productIds":selectedProductIds},
				success : function(message) {
					if(message == "200"){
		                layer.msg('操作成功!',{icon:1,time:1000},function(){
		    				parent.document.getElementById("productIds").value="";
		                    var index = parent.layer.getFrameIndex(window.name);
		                    parent.query_expire_product_form.submit();
		                    parent.layer.close(index);
		                });
					}else if(message == "500"){
						layer.alert("系统繁忙！");
					}else{
						layer.alert(message);
					}
				},complete: function(XMLHttpRequest, textStatus) {
					layer.close(layer_load_window);
				}
		  	});
	});
}
//checkbox 选中或者不选中商品
function changeSelectProduct(e){
	if(e.checked){
		parent.addProduct(e.value);
	}else{
		parent.deleteProduct(e.value);
	}
}
//全选
function allSelect(){
	if($("#chkAll2").prop("checked")){
		$("input[name='chk']").each(function(){
			$(this).prop("checked","checked");
			parent.addProduct(this.value);
		});
	}else{
		$("input[name='chk']").each(function(){
			$(this).prop("checked","");
			parent.deleteProduct(this.value);
		});
	}
}

function search(){
	     var productId=  document.getElementsByName("prodId")[0].value
	     if(productId!=''&&isNaN(productId)){ 
	         layer.layer.alert("输入的商品编号有误，请重新输入！");
	         return  ;
	     }
	     document.getElementsByName("prodId")[0].value=(document.getElementsByName("prodId")[0].value).trim(); 
	     document.getElementsByName("proName")[0].value=(document.getElementsByName("proName")[0].value).trim(); 
	     $("#page").val("1");
        $("#query_not_buy_product_list_form").submit();
	 }	
function toIsEmpty(){
   document.getElementsByName("proName")[0].value= "";
   document.getElementsByName("prodId")[0].value= "";
   document.getElementsByName("merchantQo.id")[0].value= "";
}